//
// Copyright (c) 2009 All Right Reserved
//
// vl
//
// 2009-01-01
// Contains ...
using System.Diagnostics.Contracts;
using System.Globalization;
using System.Xml.Linq;
using JetBrains.Annotations;
using LargoCommon.Abstract;
namespace LargoCommon.Music
{
///
/// Staff Change.
///
public sealed class StaffChange : AbstractChange {
#region Constructors
///
/// Initializes a new instance of the class.
///
[UsedImplicitly]
public StaffChange() {
}
///
/// Initializes a new instance of the class.
///
/// The given change.
public StaffChange(XElement xchange)
: base(xchange) {
Contract.Requires(xchange != null);
//// if (xchange == null) { return; }
this.Staff = XmlSupport.ReadByteAttribute(xchange.Attribute("Staff"));
this.Voice = XmlSupport.ReadByteAttribute(xchange.Attribute("Voice"));
this.ChangeType = MusicalChangeType.Staff;
}
///
/// Initializes a new instance of the class.
///
/// The given bar.
/// The given line.
public StaffChange(int givenBar, int givenLine)
: base(givenBar, givenLine, MusicalChangeType.Staff) {
}
#endregion
#region Properties - Xml
///
/// Gets Xml representation.
///
///
/// Property description.
///
public override XElement GetXElement {
get {
var change = base.GetXElement;
change.Add(new XAttribute("Staff", this.Staff));
change.Add(new XAttribute("Voice", this.Voice));
return change;
}
}
#endregion
#region Properties
/// Gets or sets class of melodic part.
/// Property description.
public byte Staff { get; set; }
/// Gets or sets class of melodic part.
/// Property description.
public byte Voice { get; set; }
///
/// Gets StaffVoiceString.
///
/// Property description.
[UsedImplicitly]
public string StaffVoiceString => string.Format(CultureInfo.CurrentCulture, "{0}/{1}", this.Staff, this.Voice);
#endregion
#region Public methods
///
/// Clones this instance.
///
/// Returns object.
public override object Clone() {
var tmc = new StaffChange(this.BarNumber, this.LineIndex) {
Staff = this.Staff, Voice = this.Voice
};
//// tmc.BlockModel = this.BlockModel;
return tmc;
}
#endregion
}
}